package pers.fulsun.blog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.dreamlu.mica.core.utils.ObjectUtil;
import org.springframework.stereotype.Service;
import pers.fulsun.blog.dao.UserDao;
import pers.fulsun.blog.entity.User;
import pers.fulsun.blog.service.UserService;

/**
 * 服务接口实现
 *
 * @author fl
 * @since 2021-11-29 11:19:42
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class UserServiceImpl implements UserService {
  private final UserDao userDao;

  @Override
  public User findByUsername(@NotNull String username,      @NotNull String password ) {
    User user=  userDao.getOne(new QueryWrapper<User>().lambda().eq(User::getUsername, username), false);
    if (ObjectUtil.isNotEmpty(user)) {
      if (!password.equals(user.getPassword())) {
        user = null;
      }
    }
    return user;
  }
}
